//
// C++ Interface: keyboard
//
// Description: 
//
//
// Author: Juan Linietsky <reduzio@gmail.com>, (C) 2006
//
// Copyright: See COPYING file that comes with this distribution
//
//
#ifndef PIGUIKEYBOARD_H
#define PIGUIKEYBOARD_H

#ifndef GUI_EXTERNAL_KEYBOARD

#include "base/defs.h"

namespace GUI {

/**
	@author Juan Linietsky <reduzio@gmail.com>
*/

enum KeyCode { /* List Taken from SDL */
	
	KEY_UNKNOWN,
	KEY_FIRST,
	KEY_BACKSPACE,
	KEY_TAB,
	KEY_CLEAR,
	KEY_RETURN,
	KEY_PAUSE,
	KEY_ESCAPE,
	KEY_SPACE,
	KEY_EXCLAIM,
	KEY_QUOTEDBL,
	KEY_HASH,
	KEY_DOLLAR,
	KEY_AMPERSAND,
	KEY_QUOTE,
	KEY_LEFTPAREN,
	KEY_RIGHTPAREN,
	KEY_ASTERISK,
	KEY_PLUS,
	KEY_COMMA,
	KEY_MINUS,
	KEY_PERIOD,
	KEY_SLASH,
	KEY_0,
	KEY_1,
	KEY_2,
	KEY_3,
	KEY_4,
	KEY_5,
	KEY_6,
	KEY_7,
	KEY_8,
	KEY_9,
	KEY_COLON,
	KEY_SEMICOLON,
	KEY_LESS,
	KEY_EQUALS,
	KEY_GREATER,
	KEY_QUESTION,
	KEY_AT,
	KEY_LEFTBRACKET,
	KEY_BACKSLASH,
	KEY_RIGHTBRACKET,
	KEY_CARET,
	KEY_UNDERSCORE,
	KEY_BACKQUOTE,
	KEY_a,
	KEY_b,
	KEY_c,
	KEY_d,
	KEY_e,
	KEY_f,
	KEY_g,
	KEY_h,
	KEY_i,
	KEY_j,
	KEY_k,
	KEY_l,
	KEY_m,
	KEY_n,
	KEY_o,
	KEY_p,
	KEY_q,
	KEY_r,
	KEY_s,
	KEY_t,
	KEY_u,
	KEY_v,
	KEY_w,
	KEY_x,
	KEY_y,
	KEY_z,
	KEY_DELETE,
	KEY_WORLD_0,
	KEY_WORLD_1,
	KEY_WORLD_2,
	KEY_WORLD_3,
	KEY_WORLD_4,
	KEY_WORLD_5,
	KEY_WORLD_6,
	KEY_WORLD_7,
	KEY_WORLD_8,
	KEY_WORLD_9,
	KEY_WORLD_10,
	KEY_WORLD_11,
	KEY_WORLD_12,
	KEY_WORLD_13,
	KEY_WORLD_14,
	KEY_WORLD_15,
	KEY_WORLD_16,
	KEY_WORLD_17,
	KEY_WORLD_18,
	KEY_WORLD_19,
	KEY_WORLD_20,
	KEY_WORLD_21,
	KEY_WORLD_22,
	KEY_WORLD_23,
	KEY_WORLD_24,
	KEY_WORLD_25,
	KEY_WORLD_26,
	KEY_WORLD_27,
	KEY_WORLD_28,
	KEY_WORLD_29,
	KEY_WORLD_30,
	KEY_WORLD_31,
	KEY_WORLD_32,
	KEY_WORLD_33,
	KEY_WORLD_34,
	KEY_WORLD_35,
	KEY_WORLD_36,
	KEY_WORLD_37,
	KEY_WORLD_38,
	KEY_WORLD_39,
	KEY_WORLD_40,
	KEY_WORLD_41,
	KEY_WORLD_42,
	KEY_WORLD_43,
	KEY_WORLD_44,
	KEY_WORLD_45,
	KEY_WORLD_46,
	KEY_WORLD_47,
	KEY_WORLD_48,
	KEY_WORLD_49,
	KEY_WORLD_50,
	KEY_WORLD_51,
	KEY_WORLD_52,
	KEY_WORLD_53,
	KEY_WORLD_54,
	KEY_WORLD_55,
	KEY_WORLD_56,
	KEY_WORLD_57,
	KEY_WORLD_58,
	KEY_WORLD_59,
	KEY_WORLD_60,
	KEY_WORLD_61,
	KEY_WORLD_62,
	KEY_WORLD_63,
	KEY_WORLD_64,
	KEY_WORLD_65,
	KEY_WORLD_66,
	KEY_WORLD_67,
	KEY_WORLD_68,
	KEY_WORLD_69,
	KEY_WORLD_70,
	KEY_WORLD_71,
	KEY_WORLD_72,
	KEY_WORLD_73,
	KEY_WORLD_74,
	KEY_WORLD_75,
	KEY_WORLD_76,
	KEY_WORLD_77,
	KEY_WORLD_78,
	KEY_WORLD_79,
	KEY_WORLD_80,
	KEY_WORLD_81,
	KEY_WORLD_82,
	KEY_WORLD_83,
	KEY_WORLD_84,
	KEY_WORLD_85,
	KEY_WORLD_86,
	KEY_WORLD_87,
	KEY_WORLD_88,
	KEY_WORLD_89,
	KEY_WORLD_90,
	KEY_WORLD_91,
	KEY_WORLD_92,
	KEY_WORLD_93,
	KEY_WORLD_94,
	KEY_WORLD_95,
	KEY_KP0,
	KEY_KP1,
	KEY_KP2,
	KEY_KP3,
	KEY_KP4,
	KEY_KP5,
	KEY_KP6,
	KEY_KP7,
	KEY_KP8,
	KEY_KP9,
	KEY_KP_PERIOD,
	KEY_KP_DIVIDE,
	KEY_KP_MULTIPLY,
	KEY_KP_MINUS,
	KEY_KP_PLUS,
	KEY_KP_ENTER,
	KEY_KP_EQUALS,
	KEY_UP,
	KEY_DOWN,
	KEY_RIGHT,
	KEY_LEFT,
	KEY_INSERT,
	KEY_HOME,
	KEY_END,
	KEY_PAGEUP,
	KEY_PAGEDOWN,
	KEY_F1,
	KEY_F2,
	KEY_F3,
	KEY_F4,
	KEY_F5,
	KEY_F6,
	KEY_F7,
	KEY_F8,
	KEY_F9,
	KEY_F10,
	KEY_F11,
	KEY_F12,
	KEY_F13,
	KEY_F14,
	KEY_F15,
	KEY_NUMLOCK,
	KEY_CAPSLOCK,
	KEY_SCROLLOCK,
	KEY_RSHIFT,
	KEY_LSHIFT,
	KEY_RCTRL,
	KEY_LCTRL,
	KEY_RALT,
	KEY_LALT,
	KEY_RMETA,
	KEY_LMETA,
	KEY_LSUPER,
	KEY_RSUPER,
	KEY_MODE,
	KEY_COMPOSE,
	KEY_HELP,
	KEY_PRINT,
	KEY_SYSREQ,
	KEY_BREAK,
	KEY_MENU,
	KEY_POWER,
	KEY_EURO,
	KEY_UNDO,
	KEY_MAX
};

enum KeyModifierMask {
	
	KEY_CODE_MASK=((1<<10)-1), ///< Apply this mask to any keycode to remove modifiers

	KEY_MASK_SHIFT=(1<<10), /// Adds modifier to keycode
	KEY_MASK_ALT=(1<<11), /// Adds modifier to keycode
	KEY_MASK_META=(1<<12), /// Adds modifier to keycode
	KEY_MASK_CTRL=(1<<13) /// Adds modifier to keycode
	
};


class Keyboard {
	
	static const char* key_names[KEY_MAX];
public:
	
	static String get_code_name(unsigned int p_code); ///< Keycode and modifiers accepted
	
	Keyboard();
	
	~Keyboard();

};

class KeycodeTranslator {

	unsigned int table[KEY_MAX];
public:	
	
	void add_code(unsigned int p_foreign,KeyCode p_code); //map foreign -> keycode
	KeyCode get_code(unsigned int p_foreign);
	
	KeycodeTranslator();
	virtual ~KeycodeTranslator();
};

};

#else

#include GUI_EXTERNAL_KEYBOARD

#endif

#endif
